import request from "@/utils/request";
import { AccessTokenRequest, CodeLoginReqeust, LoginResponse, RegsiterRequest, UserInfo } from "./type";

/** 验证码注册用户 */
export function fetchRegister(options: RegsiterRequest) {
  // 
  return request.post<any>('/cupid/customer/register', options, {
    suffix: false,
  })
}

/**登录获取token */
export function fetchAccessToken(options: AccessTokenRequest) {
  return request.post<LoginResponse>('/auth/oauth/token', options, {
    suffix: true,
    responseData: 'other',
    header: {
      isToken: 'false',
      Authorization: 'Basic dGVzdDp0ZXN0'
    }
  })
}

/** 手机验证码登陆获取token */
export function fetchAccessTokenWithCode(options: CodeLoginReqeust) {
  return request.post<LoginResponse>('/auth/mobile/token/sms', options, {
    suffix: true,
    responseData: 'other',
    header: {
      isToken: 'false',
      Authorization: 'Basic dGVzdDp0ZXN0'
    }
  })
}

/**获取用户信息 */
export function fetchUserInfo() {
  return request.get<UserInfo>('/cupid/customer/login-user-info')
}